package com.xinqi.modules.chat.chat.official.factory;

import com.xinqi.common.base.error.CommonErrors;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.chat.chat.official.client.ChatRemindContentClient;
import com.xinqi.modules.chat.chat.official.dto.req.ChatRemindContentBatchCreateDTO;
import com.xinqi.modules.chat.chat.official.dto.req.ChatRemindContentCreateDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 新奇提醒消息记录表降级处理
 *
 * @author: yyzhen
 * @date: 2023/05/06
 */
@Slf4j
@Component
public class ChatRemindContentFallbackFactory implements FallbackFactory<ChatRemindContentClient> {

    @Override
    public ChatRemindContentClient create(Throwable throwable) {
        log.error("新奇提醒服务调用失败:{}", throwable.getMessage());
        return new ChatRemindContentClient() {

            @Override
            public R<Boolean> insert(ChatRemindContentCreateDTO dto) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<Boolean> batchInsert(ChatRemindContentBatchCreateDTO dto) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }
        };
    }
}
